import React from 'react';
// import { Child } from 'xxx'

export class Parent extends React.Component {
  constructor() {
    super();
    this.state = {
      lastName: '王',
    };
  }

  render() {
    return (
      <div>
        <div>我是父组件，我姓：{this.state.lastName}</div>
        <Child lastName={this.state.lastName} money={this.props.money} />
      </div>
    );
  }
}

// 子组件
class Child extends React.Component {
  render() {
    console.log('子组件', this.props);
    return (
      // 显示父组件传递的数据
      <div>
        <hr />
        <div>我是子组件,我姓{this.props.lastName}</div>
        <div>我是子组件,我接收到money：{this.props.money}</div>
      </div>
    );
  }
}
